import { ref } from 'vue'
import axios from 'axios'

export default function () {
    //数据
    let dogList = ref(['https:\/\/images.dog.ceo\/breeds\/pembroke\/n02113023_6015.jpg'])

    //方法
    async function getDog() {
        try {
            let result = await axios.get('https://dog.ceo/api/breed/pembroke/images/random')
            dogList.value.push(result.data.message)
        } catch (error) {
            console.log(error)
            alert(error)
        }
    }

    //向外部提供属性
    return { dogList, getDog }
}
